% @brief 生成OptimizingGroupS中雅可比矩阵
% @param B调制度
% @param Phi 包裹相位
% @param delta 相移
% @param Q是麦克劳林系数的阶次
% @output 返回雅可比矩阵
function J = JMatrix_S_LRD(B,Phi,delta,Q,Legd_Matrix)
    Nx = size(Phi,1);
    Ny = size(Phi,2);
    N = Nx*Ny;
    %-----------------与k有关的矩阵-------------------
    kMatrix = -B.*sin(Phi+delta);
    kMatrix = reshape(kMatrix,[],1);
    %-----------------与麦克劳林系数有关的矩阵------------------
    J = zeros(N,(Q+1)*(Q+2)/2);
    for J_col =  1:(Q+1)*(Q+2)/2
        legd = reshape(Legd_Matrix(:, :, J_col), [], 1);
        J(:,J_col) =legd.*kMatrix;
    end
end